/* eslint-disable no-unused-vars */
'use strict';

module.exports = app => {
  const { STRING, INTEGER, ENUM } = app.Sequelize;

  const User = app.model.define(
    'user',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      name: {
        type: STRING(30),
        allowNull: false,
        defaultValue: '',
        comment: '姓名',
        unique: true,
      },
      user_name: {
        type: STRING(30),
        allowNull: false,
        defaultValue: '',
        comment: '用户名',
        unique: true,
      },
      password: {
        type: STRING(30),
        allowNull: false,
        defaultValue: '',
        comment: '密码',
      },
      role_type: {
        type: STRING(255),
        allowNull: false,
        defaultValue: '',
        comment: '用户角色',
      },
      head_url: {
        type: STRING(255),
        allowNull: false,
        defaultValue: '',
        comment: '头像地址',
      },
      org_id: {
        type: INTEGER,
        allowNull: true,
        comment: '组织id',
      },
      age: INTEGER,
    },
    {
      timestamps: false,
    }
  );

  return User;
};

//     freezeTableName: true,  使用自定义表名
//     // 实例对应的表名
//     tableName: 'user',
//     // 如果需要sequelize帮你维护createdAt,updatedAt和deletedAt必须先启用timestamps功能
//     // 将createdAt对应到数据库的created_at字段
//     createdAt: 'created_at',
//     // 将updatedAt对应到数据库的updated_at字段
//     updatedAt: 'updated_at',
//     //And deletedAt to be called destroyTime (remember to enable paranoid for this to work)
//     deletedAt: false, //'deleted_at',
//     //删除数据时不删除数据，而是更新deleteAt字段 如果需要设置为true，则上面的deleteAt字段不能为false，也就是说必须启用
//     paranoid: false
